import Operator from "./Operator";
import {RC} from "../config/RC";
import MessageBox from "../entities/MessageBox";
import { SYSTEM, USER } from "../config/config";
import MessageBoxForSingleUser from "../entities/MessageBoxForSingleUser";

class CreateUserMessageBoxOperator extends Operator{
    public async execute(): Promise<RC> {
        let userId: string = this.args.getProperty("generateId");
        if(userId === '' || userId === null || userId === undefined){
            return RC.INVALID_ARGUMENT;
        }
        const messageBox = new MessageBoxForSingleUser(USER,userId); // 创建一个User对象
        messageBox.insertNewMessage(SYSTEM,userId,"信箱初始化","我",userId);  // 插入数据库

        this.args.setProperty("MessageObj", messageBox);
        return RC.SUCCESS;
    }
}

export default CreateUserMessageBoxOperator;